package com.lj.generator.result.gen;

import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.lj.generator.constant.GenConstant;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * @author luojing
 * @since 2025/6/25 10:38
 */
@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
public class SqlInfo extends AbstractTemplateInfo {

    /**
     * 菜单主键id
     */
    private String menuId;

    /**
     * 分页查询主键
     */
    private String listId;

    private String infoId;

    private String saveId;

    private String updateId;

    private String deleteId;

    private String importId;

    private String exportId;

    /**
     * 当前用户id
     */
    private String userId;


    public SqlInfo(GenTemplateInfo genTemplateInfo) {
        super(genTemplateInfo);
        setFileName(genTemplateInfo.getEntity().getClassName() + GenConstant.sqlFileSuffix);
        List<String> filePath = CollUtil.newArrayList(GenConstant.sqlDir);
        setFilePath(filePath);

        menuId = IdWorker.getIdStr();
        listId = IdWorker.getIdStr();
        infoId = IdWorker.getIdStr();
        saveId = IdWorker.getIdStr();
        updateId = IdWorker.getIdStr();
        deleteId = IdWorker.getIdStr();
        importId = IdWorker.getIdStr();
        exportId = IdWorker.getIdStr();
        userId = StpUtil.getLoginIdAsString();
    }

    @Override
    public String getTemplate() {
        return GenConstant.sqlTemplate;
    }
}
